package guyubao.com.config;

import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.QueueBuilder;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * rabbitmq
 * @author wxa
 */
@Configuration
public class RabbitConfiguration {


    @Bean("emailQueue") // 定义消息队列
    public Queue emailQueue(){
        return QueueBuilder
                .durable("mail")
                .build();
    }

    // 接收JSON格式消息进行自动转换
    @Bean("jacksonConverter")   //直接创建一个用于JSON转换的Bean
    public Jackson2JsonMessageConverter converter(){
        return new Jackson2JsonMessageConverter();
    }
}
